// VsConfigDialog.cpp : implementation file
//

#include "stdafx.h"
#include "setupconfig.h"
#include "VsConfigDialog.h"

#include <ShlObj.h>


// CVsConfigDialog dialog

IMPLEMENT_DYNAMIC(CVsConfigDialog, CDialog)

CVsConfigDialog::CVsConfigDialog(const CString & dir, CWnd* pParent /*=NULL*/)
	: CDialog(CVsConfigDialog::IDD, pParent)
	, m_dir(dir)
{

}

CVsConfigDialog::~CVsConfigDialog()
{
}

void CVsConfigDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_DIR, m_dir);
}


BEGIN_MESSAGE_MAP(CVsConfigDialog, CDialog)
	ON_BN_CLICKED(IDC_BROWSE, &CVsConfigDialog::OnBnClickedBrowse)
END_MESSAGE_MAP()


// CVsConfigDialog message handlers

void CVsConfigDialog::OnBnClickedBrowse()
{
	// TODO: Add your control notification handler code here

	char name[MAX_PATH]="";
	//strcpy(name, m_dir);
	//ITEMIDLIST item = { };

	BROWSEINFO browse = { m_hWnd, 0, 0, "Select the installation directory of the Microsoft C++ compiler you want to use.", 0, 0, 0 };

	ITEMIDLIST * list = SHBrowseForFolder( &browse );

	if( list )
	{
		SHGetPathFromIDList( list, name );

		CComPtr<IMalloc> malloc;
		SHGetMalloc(&malloc);
		malloc->Free(list);

		m_dir = name;

		m_dir += '\\';  // ??

		UpdateData(FALSE);
	}
	// else: Cancel was pressed
}
